
package com.android.formula.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.android.formula.model.FormulaNote;
import com.android.formula.utils.Constants;

public class FormulaNoteDao extends BaseDao<FormulaNote> {

    public FormulaNoteDao(Class<FormulaNote> tclass, Context context, SQLiteDatabase db) {
        super(tclass, context, db);
    }

    public void deleteFormulaFromSubject(int subjectId) {
        if (mDB == null) {
            return;
        }
        String whereString = Constants.TABLE_FOMULA_COL_TYPEID + " in (select "
                + Constants.TABLE_FOMULA_COL_TYPEID + " from " + Constants.DB_TB_TYPE_FORMULA
                + " where " + Constants.TABLE_TYPE_FORMULA_COL_TYPE_SUBJECTID + "=" + subjectId
                + ")";
        
        mDB.delete(Constants.DB_TB_FORMULA, whereString, null);
    }
}
